<template>
	<view class="new__page">
		<template v-for="(temp,index) in newList">
			<navigator :url="'/pages/newDetail/newDetail?id='+temp.id" :key="index">
				<globalCard>
					<view class="title__item">{{temp.title}}</view>
					<view class="date__item">{{temp.created_at}}</view>
					<view class="tip__item">播报</view>
				</globalCard>
			</navigator>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newList: [],
			};
		},
		created() {
			this.main()
		},
		methods: {
			async main() {
				await this.getNesList();
			},
			async getNesList() {
				uni.showLoading({
						title: '加载中...',
						mask: true
					})
				const [err, result] = await this.$https({
					url: '/wechat/getallnews',
					method: "POST",
					data: {
						page: 1
					}

				})
				uni.hideLoading()
				if (result.statusCode == 500) {
					uni.switchTab({
						url: '/pages/wode/wode',
						fail: (err) => {
							console.log(err)
						}
					})
					uni.showToast({
						title: '请先登录',
						icon: 'none'
					})
				}
				this.newList = result.data.data;
				console.log(this.newList)
			}
		}
	}
</script>

<style lang="scss">
	.new__page {
		min-height: 100vh;
		box-sizing: border-box;
		padding: 20px;
		background-color: #F1F1F1;
		position: relative;

		.title__item {
			font-size: 18px;
			font-weight: bold;
		}

		.date__item {
			font-size: 14px;
			color: #aaa;
			position: absolute;
			bottom: 20px;
		}

		.tip__item {
			position: absolute;
			right: 20px;
			bottom: 20px;
			font-size: 12px;
			color: $miva-color-base;
		}
	}
</style>
